// pages/my/refund.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    no_pic:'/static/images/no-pic.png',
    item_lx:['仅退款'],
    id:'',
    sub:{id:'',lx:'仅退款',price:'',note:''},
    info:{id:0}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      'sub.id':options.id
    })
    this.load();
  },
  setInput(e){
    let key=e.currentTarget.dataset.key;
    this.setData({
      [key]:e.detail.value
    })
  },
  sqlx(){
    let that=this;
    wx.showActionSheet({
      title:"请选择申请类型",
      itemList: this.data.item_lx,
      success: function (res) {
        that.setData({
          'sub.lx':that.data.item_lx[res.tapIndex]
        })
      }
    });
  },
  async load(){
    let res=await wx.util.post("order/detail",{id:this.data.sub.id});
    this.setData({
      info:res.data,
      'sub.price':res.data.price_payed
    })
  },
  async subAc(){
    if(this.data.sub.lx==""  || this.data.sub.note==""){
      wx.util.toast('请将表单填写完整！');
      return;
    }
    await wx.util.post("order_refund/sub",this.data.sub,false);
    wx.navigateBack({
      delta:1
    })
  }
})